PalindromeΒΆ

Write a python function that checks whether a passed string is palindrome or not.
Note:
A palindrome is a word, phrase, or sequence that reads
the same backward as forward, e.g., madam or nurses run.
def is_palindrome(S):
    l = 0
    r = len(S) - 1
    while r >= l:
        if not S[l] == S[r]:
            return False
        l += 1
        r -= 1
    return True

def is_palindrome_01(S):
    return all(S[i] == S[-i-1] for i in range(len(S) // 2))

Test:

S = "abcdzdcba"
print(is_palindrome(S))           # True
print(is_palindrome_01(S))        # True